using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Win32;

namespace SnarlGMailNotifier.Classes.BrowserInformation
{
    public class BrowserItem
    {
        private string m_sBrowserKey = null;
        private string m_sBrowserName = null;
        private BrowserIcon m_browserIcon = null;
        private string m_sCommand = null;

        public BrowserItem(RegistryKey browserKey)
        {
            RegistryKey regDefaultIcon = browserKey.OpenSubKey("DefaultIcon\\");
            RegistryKey regOpenCommand = browserKey.OpenSubKey("shell\\open\\command\\");

            string[] splittedKey = browserKey.Name.Split('\\');
            
            this.m_sBrowserKey = splittedKey[splittedKey.Length - 1];
            this.m_sBrowserName = browserKey.GetValue("").ToString();
            this.m_browserIcon = new BrowserIcon(regDefaultIcon.GetValue("").ToString());
            this.m_sCommand = regOpenCommand.GetValue("").ToString();
        }

        public void OpenWebsite(Uri url)
        {
            BrowserFetcher.OpenWebsite(this, url);
        }

        public string BrowserKey
        {
            get { return this.m_sBrowserKey; }
        }

        public string BrowserName
        {
            get { return this.m_sBrowserName; }
        }

        public BrowserIcon IconDetails
        {
            get { return this.m_browserIcon; }
        }

        public string Command
        {
            get { return this.m_sCommand; }
        }
    }
}
